import { DrawerFormInlineType, ModalFormInlineType } from "./type";

export const countryCodeOptions = ref<any>([]);
export const helpRef = ref<any>(null);
export const formInline = reactive<any>({});
export const resetFormInline = (formState) => {
  const defaultFormInline = reactive<DrawerFormInlineType>({
    id: undefined,
    username: undefined,
    role_id: undefined,
    name: undefined,
    mobile_number: undefined,
    mobile_area: undefined,
    status: 0,
    image: undefined,
    desc: undefined,
    password: undefined,
    confirm_password: undefined,
  });
  Object.keys(defaultFormInline).forEach((key) => {
    formState[key] = defaultFormInline[key];
  });
};
resetFormInline(formInline);
export const set_formInline = (type: string, formInline: any, data: any) => {
  resetFormInline(formInline);
  if (type === "edit") {
    initObjAttr(formInline, data, "target");
  }
};
export const modalFormInline = reactive<ModalFormInlineType>({
  id: undefined,
  password_old: undefined,
  password_new: undefined,
  password_new_confirmation: undefined,
});
export const modalInputValidators = reactive(createArray(false, 2));
export const drawerInputValidators = reactive(createArray(false, 3));
export const modal_disable_ok_button = computed(() => {
  return (
    isEmptyType(modalFormInline.password_new) ||
    isEmptyType(modalFormInline.password_new_confirmation) ||
    modalInputValidators.some((bool) => bool === true)
  );
});
export const operateType = ref<any>("");
export const staffStatusMap = [
  { label: getProxyT("dict6"), value: "Infinity" },
  { label: getProxyT("dict7"), value: 0 },
  { label: getProxyT("dict8"), value: 1 },
];
export const tablePage = renderTablePage();
export const searchParams = reactive<any>({});
export const tableLoading = ref<any>(false);
export const addLoading = ref<any>(false);
export const roleOptions = ref([]);
